﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.Runtime.Serialization;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;

namespace XbdSoft.Domain
{
    [DataContract]
    [Table("Article1")]
    public class AudioResource:INotifyPropertyChanged
    {
        [DataMember]
        [Column("ArticleID")]
        public int ID { get; set; }

        [DataMember]
        [NotMapped()]
        public string Type { get; set; }
         
        [DataMember]
        [Column("Title")]
        public string Title { get; set; }

        [DataMember]
        [Column("Title1")]
        public string Title1 { get; set; }

        [DataMember]
        [Column("age")]
        public string Time { get; set; }

        [DataMember]
        [Column("Hits")]
        public int BrowserCount { get; set; }

        [DataMember]
        [Column("DownHits")]
        public int DownloadCount { get; set; }

        [DataMember]
        [Column("DefaultPicUrl")]
        public string ThumbnailImgUrl { get; set; }

        #region Detail Information

        [DataMember]
        [Column("Author")]
        public string Author { get; set; }

        [DataMember]
        [Column("KeyV108")]
        public string KeyWords { get; set; }

        [DataMember]
        [Column("aged")]
        public string SuitableAges { get; set; }

        //[DataMember]
        [Column("Content")]
        public string Description { get; set; }
        
        #endregion

        #region For UI
        private bool selected = false;

        [DataMember]
        [NotMapped()]
        public bool Selected 
        {
            get { return selected; }
            set
            {
                if (selected != value)
                {
                    selected = value;
                    OnPropertyChanged("Selected");
                }
            }
        }

        #endregion
         
        public event PropertyChangedEventHandler PropertyChanged;
        protected virtual void OnPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }

        [Column("SpecialID")] 
        [DataMember]
        public int AudioCategoryID { get; set; }

        [ForeignKey("AudioCategoryID")]
        //[DataMember]
        public AudioCategory AudioCategory { get; set; }

        [Column("ClassID")]
        [DataMember]
        public int ClassID { get; set; } 

        [Column("Deleted")]
        [DataMember]
        public bool Deleted { get; set; }

        [Column("Passed")]
        [DataMember]
        public bool Passed { get; set; }
    }

    [DataContract]
    public class AudioResourceDTO
    {
        [DataMember]
        public List<AudioResource> AudioResources { get; set; }
        [DataMember]
        public int TotalCount { get; set; }
    }
}
